//
//  ST_PushPeculiarityChildCell.swift
//  btvideo
//
//  Created by mac on 2020/1/13.
//  Copyright © 2020 JarvanZhang. All rights reserved.
//

import UIKit
import SwifterSwift


class ST_PushPeculiarityChildCell: UICollectionViewCell {
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        contentView.addSubview(cover_image_view)
        cover_image_view.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(8)
            make.bottom.equalToSuperview().offset(-7)
            make.left.equalToSuperview().offset(15)
            make.width.equalTo(cover_image_view.snp.height)
        }
        
        contentView.addSubview(content_label)
        content_label.snp.makeConstraints { (make) in
            make.top.equalTo(cover_image_view).offset(9)
            make.left.equalTo(cover_image_view.snp.right).offset(10)
        }
        
        contentView.addSubview(content_subscribe_label)
        content_subscribe_label.snp.makeConstraints { (make) in
            make.bottom.equalTo(cover_image_view).offset(-9)
            make.left.equalTo(cover_image_view.snp.right).offset(10)
        }
        
        
        
        contentView.addSubview(click_btn)
        click_btn.snp.makeConstraints { (make) in
            make.right.equalToSuperview().offset(-15)
            make.centerY.equalToSuperview()
            make.width.height.equalTo(24)
        }
        
        
        
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    

    fileprivate lazy var cover_image_view:UIImageView = {
        let control = UIImageView()
        control.contentMode = UIView.ContentMode.scaleAspectFill
        control.cornerRadius = 10
        return control
    }()
    
    fileprivate lazy var content_label:UILabel = {
        let control = UILabel.init()
        control.text = ""
        control.textColor = Color.init(hexString: "#333333")
//        control.numberOfLines = 0
//        control.textAlignment = .center
        control.font = UIFont.systemFont(ofSize: 16, weight: UIFont.Weight.semibold)
        
//        control.backgroundColor = .random
        return control
    }()
    
    fileprivate lazy var content_subscribe_label:UILabel = {
        let control = UILabel.init()
        control.text = ""
        control.textColor = Color.init(hexString: "#ACB4C0")
//        control.numberOfLines = 0
//        control.textAlignment = .center
        control.font = UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.regular)
        
//        control.backgroundColor = .random
        return control
    }()
    
    fileprivate lazy var click_btn:UIButton = {
        let control = UIButton.init(type: UIButton.ButtonType.custom)
        control.setImageForAllStates(ST_ImageUtils.imageName("个人中心_icon_选择sel")!)
        control.isHidden = true
        
        return control
    }()
    
    
    
    var model = ST_PeculiarityModel(){
        didSet{
            
            cover_image_view.pin_setImage(from: model.image.compress_image().url, placeholderImage: ST_SwiftConst.shared.fetch_random_place_holder_image())
            
            content_label.text = model.name
            
            if let sex = ST_BTUserInfoManager.shared.current_account_info?.userinfo?.sex , sex == .female{
                content_subscribe_label.text = model.like_num.st_number_description()+"个男生"
            }else{
                content_subscribe_label.text = model.like_num.st_number_description()+"个女生"
            }
            
            click_btn.isHidden = !model.isSelected
        }
    }
    
}



 

